package com.wenjie.original.entity;


import com.mybatisflex.annotation.EnumValue;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.wenjie.common.enumHandler.IEnum;
import com.wenjie.original.entity.common.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;

@Data
@Table("sys_role")
@NoArgsConstructor
@ApiModel("角色表 ")
public class SysRole extends BaseEntity {

    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @ApiModelProperty("角色ID")
    private Long sysRoleId;

    @ApiModelProperty("角色名称")
    private String roleName;

    @ApiModelProperty("角色状态（0正常 1停用）")
    private STATUS status;

    @Getter
    @AllArgsConstructor
    public enum STATUS implements IEnum<Integer> {
        arg0(0, "正常"),
        arg1(1, "停用");

        @EnumValue
        private Integer code;
        private String message;

        /**
         * @Description 通过code进行查询枚举值
         * @author wenjie
         * @date 2024/5/30 15:21
         */
        public static STATUS getBycode(Integer code) {
            return Arrays.stream(STATUS.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
        }
    }


}
